home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 5
/
Amiga Plus Sonderheft 1996 #5.iso
/
programme
/
xanimamigabeta7
/
xanim_picasso.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-16
|
4KB
|
141 lines
#include <vilintuisup/screenmode.h>
#include <vilintuisup/vilintuisup_protos.h>
#include <graphics/gfxbase.h>
#include <graphics/displayinfo.h>
/*#include <vilintuisup/vilintuisup.c> */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
/* Here I fill in the neccessary options for a 320x200x8 screen. */
/* Possible values for the depth is 8,15,16,24. If some other */
/* is supplied it will use the best mode possible. See Autodocs for more details. */
struct TagItem tag[]={
{TAVIS_SCREEN_HEIGHT,200},
{TAVIS_SCREEN_WIDTH,320},
{TAVIS_SCREEN_DEPTH,8},
{TAG_DONE,0}
};
struct TagItem openscreentags[] = {
{ TAVIS_SCREEN_MODEID, 0 }, /* ti.Data used to check for OK from Req */
{ TAVIS_AUTOSCROLL, TRUE },
{ TAVIS_OPEN_BEHIND, FALSE },
{ TAVIS_SCREEN_HEIGHT, 0 }, /* to specify a new height */
{ TAVIS_SCREEN_WIDTH, 0 },
{ TAG_DONE, 0 }
};
/*
* TagItems for the VillageModeRequest call
*/
struct TagItem requesttags[] = {
{ TAVIS_MINDEPTH, 8 },
{ TAVIS_MAXDEPTH, 16 },
{ TAG_DONE, 0 }
};
struct Library *VilIntuiBase; /* Pointer to the Vilintuisup.library. */
struct Screen *picasso_scr; /* pointer to the screen structure */
char *picasso_mem; /* pointer to the address of the Picasso screen */
/*
* It might be usefull to have a function, which will return the
* height, width or depth of a DisplayID. The next function will
* do the job. Specify an ID and the dimension you want to get.
* After a call the function returns the dimension value or -1.
*/
/*
* Define more if you want to
*/
#define GDF_HEIGHT 0
#define GDF_WIDTH 1
#define GDF_DEPTH 2
LONG GetDimFromID(ULONG ID, ULONG Tag)
{
DisplayInfoHandle Handle;
struct DimensionInfo dimension;
if (ID != INVALID_ID)
{
if (Handle = FindDisplayInfo(ID))
{
if (GetDisplayInfoData(Handle,(UBYTE *)&dimension,sizeof(dimension),DTAG_DIMS,0))
{
switch(Tag)
{
case GDF_HEIGHT:
return dimension.Nominal.MaxY+1;
break;
case GDF_WIDTH:
return dimension.Nominal.MaxX+1;
break;
case GDF_DEPTH:
return dimension.MaxDepth;
break;
default:
fprintf(stderr,"Invalid Tag for GetDimFromID() function\n");
return -1;
break;
}
}
}
}
return -1;
}
OpenPicasso()
{
int k;
int i;
/* the Picasso have to be installed and running to use this program. */
if(!(VilIntuiBase=OpenLibrary("vilintuisup.library",2))) {
printf("Can't open vilintuisup.library.");
exit(20);
}
fprintf(stderr,"Vilintuisup.library opened\n");
if ((openscreentags[0].ti_Data = VillageModeRequest(requesttags)) != INVALID_ID)
{
fprintf(stderr,"Screenmode requestor opened and closed\n");
openscreentags[3].ti_Data = GetDimFromID(openscreentags[0].ti_Data, GDF_HEIGHT);
openscreentags[4].ti_Data = GetDimFromID(openscreentags[0].ti_Data, GDF_WIDTH);
fprintf(stderr,"Screen Width= %ld\n",openscreentags[3].ti_Data);
fprintf(stderr,"Screen Height=%ld\n",openscreentags[4].ti_Data);
/* Open the Screen with the supplied tags. And exit if it fails in any way. */
/* I could check what went wrong, but I don't. :) */
if(!(picasso_scr=OpenVillageScreenTagList(openscreentags)))
{
printf("Can't open screen...");
ClosePicasso();
exit(20);
}
/* Here I forbid multitasking. I think I only have to forbid it while */
/* doing the lock, but to be on the safe side... :) */
Forbid();
/* Here the actual pointer to the videomem on the Picasso is taken. */
picasso_mem=LockVillageScreen(picasso_scr);
/* Release pointer to videomem. */
UnLockVillageScreen(picasso_scr);
Permit();
}
/* The rest I think is quite obviuos. */
}
ClosePicasso()
{
if(picasso_scr) CloseVillageScreen(picasso_scr);
if(VilIntuiBase) CloseLibrary(VilIntuiBase);
}